﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PO_2011;

namespace WindowsFormsApplication1
{
    public partial class Mediana : Form
    {
        private Pnm p;
        private int MacierzWidthIHight = 7;
        public Form1 refToMainWindow;
        public Bitmap oryginalB;

        public Mediana(Pnm objectPnm)
        {
            InitializeComponent();
            p = objectPnm; oryginalB = new Bitmap(p.getBitmap());
            pictureBox1.Size = new System.Drawing.Size(p.GetWidth, p.GetHeight);
            this.ClientSize = new System.Drawing.Size(p.GetWidth + 150, p.GetHeight + 150);
            pictureBox1.Image = p.getBitmap(); comboBox1.Text = "7x7";
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string s = comboBox1.SelectedItem.ToString();
            if (s == "3x3")
            {
                MacierzWidthIHight = 3;
            }
            else
                if (s == "7x7")
                {
                    MacierzWidthIHight = 7;
                }
                else
                {
                    MacierzWidthIHight = 5;
                }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.refToMainWindow.pictureBox1.Image = p.BitmapFiltr;
            p.bitmap = p.BitmapFiltr;
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            p.bitmapOryginal = oryginalB;
            pictureBox1.Image = p.Mediana(MacierzWidthIHight);
        }
    }
}
